var apiRoot = 'http://app213.51edn.com/api/index.php';
var webRoot = 'http://app213.51edn.com';
var payRoot = 'http://app213.51edn.com/pay/apppay/Alipay.php';
var WebRoot = 'http://app213.51edn.com/pay/webpay/pay.php';
var p1=/^(13[0-9]\d{8}|15[0-35-9]\d{8}|18[0-9]\d{8}|14[57]\d{8})$/;//手机号码格式验证
var p2=	/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;
var p3  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

//消息提示 
var toast = function(message){
	plus.nativeUI.toast(message);
}


// 后台添加的图片请使用该方法
function getImgUrl(relativeImgUrl) {
	return relativeImgUrl ? (relativeImgUrl.indexOf('http') < 0 ? webRoot + relativeImgUrl : relativeImgUrl) : '../images/me.png';
}

//跳转页面
var goUrl = function(url) {
	plus.webview.open(url, url, {}, 'slide-in-right');
}
//加载h5
document.addEventListener('plusready', function() {
	plus.webview.currentWebview().setStyle({
		scrollIndicator: 'none'
	});
	
	$('.mui-bar-nav').on('longtap','.mui-action-back',function(){
		mui.back();
	})
})
//等待提示
function showWaiting(message,time){
	if(!time || time==0){
		time = 10000;
	}
	var waiting = plus.nativeUI.showWaiting(message,{width:'80px',height:'80px',background:'rgba(0,0,0,0.3)'});
	setTimeout(function(){
		if(waiting){
			waiting.close();
		}
	},time);
}
function toUrl(url) {
	var aniShow = arguments[1] ? arguments[1] : 'slide-in-right';
	plus.nativeUI.showWaiting();
	var my = plus.webview.currentWebview();
	var idstr = url.substr(url.indexOf("/") + 1);
	idstr = idstr.substr(0, idstr.indexOf('?'));
	var ws = plus.webview.getWebviewById(idstr);
	//	alert(ws);
	if (my.id == idstr) {
		my.reload();
		plus.nativeUI.closeWaiting();
		return;
	}
	if (ws) {
		ws.reload();
		ws.show(aniShow);
		my.hide();
		plus.nativeUI.closeWaiting();
	} else {
		plus.webview.open(url, idstr, {}, aniShow);
		plus.nativeUI.closeWaiting();
	}
}
//判断用户是否登陆
var isLogin = function(page , uid){
	if(!uid){
		toast('请注册本软件在操作');
		plus.webview.create('My-information.html' , 'My-information.html' ,  {} , {spage : page}).show('slide-in-right');
		return;
	}
}

//下拉刷新
function PullToRefresh(ws){
	ws=plus.webview.currentWebview();
	ws.setPullToRefresh({support:true,
		height:"50px",
		range:"200px",
		contentdown:{  
			caption:"下拉可以刷新"
		},
		contentover:{
			caption:"释放立即刷新"
		},
		contentrefresh:{
			caption:"正在刷新..."
		} 
	},function(){
		setTimeout(function(){
			ws.reload('none');
			ws.endPullToRefresh();
		},1500);
	});
}


function memberInfo(){
	
	var memberInfo = plus.storage.getItem('memberInfo');
		
}
